package com.example.config;

import com.example.Filter.LoginCheckFilter;
import com.example.interceptor.LoginCheckinterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import javax.servlet.http.WebConnection;

//配置类--注册拦截器-
@Configuration
public class WebConfig implements WebMvcConfigurer {
    @Autowired
    private LoginCheckinterceptor addInterceptor;
    //注册拦截器
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        //调用registry方法 addInterceptor 参数是 addInterceptor
        registry.addInterceptor(addInterceptor).addPathPatterns("/**").excludePathPatterns("/login");
        /*addPathPatterns拦截路径是，/** 所有
        excludePathPatterns 不拦截
        拦截所有 /*拦截一级目录 不拦截二级
         /depts/* 只能拦截depts/下的二级目录
         /depts/** 只能拦截depts/下的所有目录 不能拦截 /select目录

         */


    }
}
